/**
 * 
 */
package com.ffcs.crmd.tsp.server.jdbc.delegate;

import java.sql.Connection;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;

import com.ffcs.crmd.tsp.common.exception.TspException;
import com.ffcs.crmd.tsp.common.exception.TspTransactionException;
import com.ffcs.crmd.tsp.server.jdbc.entity.Job;
import com.ffcs.crmd.tsp.server.jdbc.entity.JobDetail;
import com.ffcs.crmd.tsp.server.jdbc.entity.JobDetailParam;
import com.ffcs.crmd.tsp.server.jdbc.entity.JobGroup;
import com.ffcs.crmd.tsp.server.jdbc.entity.JobIdentityInfo;
import com.ffcs.crmd.tsp.server.jdbc.entity.Slice;
import com.ffcs.crmd.tsp.server.jdbc.entity.SliceGroup;
import com.ffcs.crmd.tsp.server.jdbc.entity.TaskIdentity;
import com.ffcs.crmd.tsp.server.jdbc.service.IJobDetailParamService;
import com.ffcs.crmd.tsp.server.jdbc.service.IJobDetailService;
import com.ffcs.crmd.tsp.server.jdbc.service.IJobGroupService;
import com.ffcs.crmd.tsp.server.jdbc.service.IJobIdentityInfoService;
import com.ffcs.crmd.tsp.server.jdbc.service.IJobService;
import com.ffcs.crmd.tsp.server.jdbc.service.ISliceGroupService;
import com.ffcs.crmd.tsp.server.jdbc.service.ISliceService;
import com.ffcs.crmd.tsp.server.jdbc.service.ITaskIdentityService;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.JobDetailParamServiceImpl;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.JobDetailServiceImpl;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.JobGroupServiceImpl;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.JobIdentityInfoServiceImpl;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.JobServiceImpl;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.SliceGroupServiceImpl;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.SliceServiceImpl;
import com.ffcs.crmd.tsp.server.jdbc.service.impl.TaskIdentityServiceImpl;

/**
 * 功能说明:
 *
 * @author FFCS-ZHONGFUHUA
 * 
 * @since 
 *
 */
public class ServiceDelegateTX implements ServiceDelegate {
    
    private IJobGroupService        jobGroupService;
    
    private IJobService             jobService;
    
    private IJobDetailService       jobDetailService;
    
    private IJobDetailParamService  jobDetailParamService;
    
    private IJobIdentityInfoService jobIdentityInfoService;
    
    private ISliceService           sliceService;
    
    private ISliceGroupService      sliceGroupService;
    
    private ITaskIdentityService    taskIdentityService;
    
    public ServiceDelegateTX() {
        jobDetailParamService = new JobDetailParamServiceImpl();
        jobDetailService = new JobDetailServiceImpl();
        jobIdentityInfoService = new JobIdentityInfoServiceImpl();
        taskIdentityService = new TaskIdentityServiceImpl();
        sliceService = new SliceServiceImpl();
        sliceGroupService = new SliceGroupServiceImpl();
        jobService= new JobServiceImpl();
        jobGroupService = new JobGroupServiceImpl();
        
        jobDetailService.setJobDetailParamService(jobDetailParamService);
        taskIdentityService.setJobIdentityInfoService(jobIdentityInfoService);
        sliceGroupService.setSliceService(sliceService);
        jobService.setJobDetailService(jobDetailService);
        jobService.setJobIdentityInfoService(jobIdentityInfoService);
        jobService.setSliceGroupService(sliceGroupService);
        jobGroupService.setJobService(jobService);
        jobGroupService.setTaskIdentityService(taskIdentityService);
    }
    
    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobGroup
     * @throws TspTransactionException 
     */
    @Override
    public void addJobGroup(Connection conn, JobGroup jobGroup) throws TspTransactionException {
        try {
            if(jobGroupService.get(conn, jobGroup) != null){
                throw new TspTransactionException(String.format("该任务组[%s]已经存在，不允许重复添加.", jobGroup.getName()));
            }
            jobGroupService.add(conn, jobGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobGroup
     * @throws TspTransactionException
     */
    @Override
    public void updateJobGroup(Connection conn, JobGroup jobGroup) throws TspTransactionException {
        try {
            jobGroupService.update(conn, jobGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobGroup
     * @throws TspTransactionException
     */
    @Override
    public void deleteJobGroup(Connection conn, JobGroup jobGroup) throws TspTransactionException {
        try {
            jobGroupService.delete(conn, jobGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @return
     * @throws TspException 
     */
    @Override
    public JobGroup getJobGroup(Connection conn, JobGroup jobGroup) throws TspTransactionException {
        try {
            return jobGroupService.get(conn, jobGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }


    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobGroup
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobGroup> queryJobGroup(Connection conn, JobGroup jobGroup) throws TspTransactionException {
        try {
            return jobGroupService.query(conn, jobGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobGroup
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobGroup> queryJobGroupPage(Connection conn, JobGroup jobGroup) throws TspTransactionException {
        try {
            return jobGroupService.queryPage(conn, jobGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @throws TspTransactionException
     */
    @Override
    public void addJob(Connection conn, Job job) throws TspTransactionException {
        try {
            if(jobService.get(conn, job) != null){
                throw new TspTransactionException(String.format("该任务[%s]已经存在，不允许重复添加.", job.getName()));
            }
            jobService.add(conn, job);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @throws TspTransactionException
     */
    @Override
    public void updateJob(Connection conn, Job job) throws TspTransactionException {
        try {
            jobService.update(conn, job);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @throws TspTransactionException
     */
    @Override
    public void deleteJob(Connection conn, Job job) throws TspTransactionException {
        try {
            jobService.delete(conn, job);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @return
     * @throws TspTransactionException
     */
    @Override
    public Job getJob(Connection conn, Job job) throws TspTransactionException {
        try {
            return jobService.get(conn, job);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<Job> queryJob(Connection conn, Job job) throws TspTransactionException {
        try {
            return jobService.query(conn, job);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<Job> queryJobPage(Connection conn, Job job) throws TspTransactionException {
        try {
            return jobService.queryPage(conn, job);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @throws TspTransactionException
     */
    @Override
    public Long addJobDetail(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            if(jobDetailService.get(conn, jobDetail) != null){
                throw new TspTransactionException(String.format("该子任务[%s]已存在，不允许重复添加.", jobDetail.getName()));
            }
            return jobDetailService.add(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @throws TspTransactionException
     */
    @Override
    public void updateJobDetail(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            jobDetailService.update(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @throws TspTransactionException
     */
    @Override
    public void deleteJobDetail(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            jobDetailService.delete(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @throws TspTransactionException
     */
    @Override
    public void pauseJobDetail(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            jobDetailService.pause(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @throws TspTransactionException
     */
    @Override
    public void resumeJobDetail(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            jobDetailService.resume(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @return
     * @throws TspTransactionException
     */
    @Override
    public JobDetail getJobDetail(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            return jobDetailService.get(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobDetail> queryJobDetail(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            return jobDetailService.query(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }
    
    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @return
     * @throws TspTransactionException
     */
    @Override
    public int queryJobDetailSize(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            return jobDetailService.querySize(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetail
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobDetail> queryJobDetailPage(Connection conn, JobDetail jobDetail) throws TspTransactionException {
        try {
            return jobDetailService.queryPage(conn, jobDetail);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetailParam
     * @throws TspTransactionException
     */
    @Override
    public void addJobDetailParam(Connection conn, JobDetailParam jobDetailParam) throws TspTransactionException {
        try {
            if(jobDetailParamService.get(conn, jobDetailParam) != null){
                throw new TspTransactionException(String.format("该参数[%s]已经存在，不允许重复添加.", jobDetailParam.getMkey()));
            }
            jobDetailParamService.add(conn, jobDetailParam);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }
    
    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetailParam
     * @throws TspTransactionException
     */
    @Override
    public void updateJobDetailParam(Connection conn, JobDetailParam jobDetailParam) throws TspTransactionException {
        try {
            jobDetailParamService.update(conn, jobDetailParam);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetailParam
     * @throws TspTransactionException
     */
    @Override
    public void deleteJobDetailParam(Connection conn, JobDetailParam jobDetailParam) throws TspTransactionException {
        try {
            jobDetailParamService.delete(conn, jobDetailParam);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetailParam
     * @return
     * @throws TspTransactionException
     */
    @Override
    public JobDetailParam getJobDetailParam(Connection conn, JobDetailParam jobDetailParam) throws TspTransactionException {
        try {
            return jobDetailParamService.get(conn, jobDetailParam);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetailParam
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobDetailParam> queryJobDetailParam(Connection conn, JobDetailParam jobDetailParam) throws TspTransactionException {
        try {
            return jobDetailParamService.query(conn, jobDetailParam);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetailParam
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobDetailParam> queryJobDetailParamPage(Connection conn, JobDetailParam jobDetailParam) throws TspTransactionException {
        try {
            return jobDetailParamService.queryPage(conn, jobDetailParam);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobIdentityInfo
     * @throws TspTransactionException
     */
    @Override
    public void addJobIdentityInfo(Connection conn, JobIdentityInfo jobIdentityInfo) throws TspTransactionException {
        try {
            if(jobIdentityInfoService.get(conn, jobIdentityInfo) != null){
                throw new TspTransactionException(String.format("该执行端实例[%s]已经存在，不允许重复添加.", jobIdentityInfo.getIdentity()));
            }
            jobIdentityInfoService.add(conn, jobIdentityInfo);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }


    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobIdentityInfo
     * @throws TspTransactionException
     */
    @Override
    public void deleteJobIdentityInfo(Connection conn, JobIdentityInfo jobIdentityInfo) throws TspTransactionException {
        try {
            jobIdentityInfoService.delete(conn, jobIdentityInfo);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobIdentityInfo
     * @return
     * @throws TspTransactionException
     */
    @Override
    public JobIdentityInfo getJobIdentityInfo(Connection conn, JobIdentityInfo jobIdentityInfo) throws TspTransactionException {
        try {
            return jobIdentityInfoService.get(conn, jobIdentityInfo);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobIdentityInfo
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobIdentityInfo> queryJobIdentityInfo(Connection conn, JobIdentityInfo jobIdentityInfo) throws TspTransactionException {
        try {
            return jobIdentityInfoService.query(conn, jobIdentityInfo);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobIdentityInfo
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<JobIdentityInfo> queryJobIdentityInfoPage(Connection conn, JobIdentityInfo jobIdentityInfo) throws TspTransactionException {
        try {
            return jobIdentityInfoService.queryPage(conn, jobIdentityInfo);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param slice
     * @throws TspTransactionException
     */
    @Override
    public void addSlice(Connection conn, Slice slice) throws TspTransactionException {
        try {
            if(sliceService.get(conn, slice) != null){
                throw new TspTransactionException(String.format("该分片[%s]已经存在，不允许重复添加.", slice.getSkey()));
            }
            sliceService.add(conn, slice);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param slice
     * @throws TspTransactionException
     */
    @Override
    public void updateSlice(Connection conn, Slice slice) throws TspTransactionException {
        try {
            sliceService.update(conn, slice);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param slice
     * @throws TspTransactionException
     */
    @Override
    public void deleteSlice(Connection conn, Slice slice) throws TspTransactionException {
        try {
            sliceService.delete(conn, slice);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param slice
     * @return
     * @throws TspTransactionException
     */
    @Override
    public Slice getSlice(Connection conn, Slice slice) throws TspTransactionException {
        try {
            return sliceService.get(conn, slice);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param slice
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<Slice> querySlice(Connection conn, Slice slice) throws TspTransactionException {
        try {
            return sliceService.query(conn, slice);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param slice
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<Slice> querySlicePage(Connection conn, Slice slice) throws TspTransactionException {
        try {
            return sliceService.queryPage(conn, slice);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param sliceGroup
     * @throws TspTransactionException
     */
    @Override
    public void addSliceGroup(Connection conn, SliceGroup sliceGroup) throws TspTransactionException {
        try {
            if(sliceGroupService.get(conn, sliceGroup) != null){
                throw new TspTransactionException(String.format("该分片组[%s]已经存在，不允许重复添加.", sliceGroup.getName()));
            }
            sliceGroupService.add(conn, sliceGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param sliceGroup
     * @throws TspTransactionException
     */
    @Override
    public void updateSliceGroup(Connection conn, SliceGroup sliceGroup) throws TspTransactionException {
        try {
            sliceGroupService.update(conn, sliceGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param sliceGroup
     * @throws TspTransactionException
     */
    @Override
    public void deleteSliceGroup(Connection conn, SliceGroup sliceGroup) throws TspTransactionException {
        try {
            sliceGroupService.delete(conn, sliceGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param sliceGroup
     * @return
     * @throws TspTransactionException
     */
    @Override
    public SliceGroup getSliceGroup(Connection conn, SliceGroup sliceGroup) throws TspTransactionException {
        try {
            return sliceGroupService.get(conn, sliceGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param sliceGroup
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<SliceGroup> querySliceGroup(Connection conn, SliceGroup sliceGroup) throws TspTransactionException {
        try {
            return sliceGroupService.query(conn, sliceGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param sliceGroup
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<SliceGroup> querySliceGroupPage(Connection conn, SliceGroup sliceGroup) throws TspTransactionException {
        try {
            return sliceGroupService.queryPage(conn, sliceGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param taskIdentity
     * @throws TspTransactionException
     */
    @Override
    public void addTaskIdentity(Connection conn, TaskIdentity taskIdentity) throws TspTransactionException {
        try {
            TaskIdentity taskIdentityParam = new TaskIdentity();
            taskIdentityParam.setClusterName(taskIdentity.getClusterName());
            taskIdentityParam.setIdentity(taskIdentity.getIdentity());
            taskIdentityParam.setJobGroupId(taskIdentity.getJobGroupId());
            if(CollectionUtils.isNotEmpty(taskIdentityService.query(conn, taskIdentityParam))){
                throw new TspTransactionException(String.format("当前任务组下已存在该执行端实例[%s]，不允许重复添加.", taskIdentity.getIdentity()));
            }
            taskIdentityService.add(conn, taskIdentity);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param taskIdentity
     * @throws TspTransactionException
     */
    @Override
    public void updateTaskIdentity(Connection conn, TaskIdentity taskIdentity) throws TspTransactionException {
        try {
            taskIdentityService.update(conn, taskIdentity);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param taskIdentity
     * @throws TspTransactionException
     */
    @Override
    public void deleteTaskIdentity(Connection conn, TaskIdentity taskIdentity) throws TspTransactionException {
        try {
            taskIdentityService.delete(conn, taskIdentity);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param taskIdentity
     * @return
     * @throws TspTransactionException
     */
    @Override
    public TaskIdentity getTaskIdentity(Connection conn, TaskIdentity taskIdentity) throws TspTransactionException {
        try {
            return taskIdentityService.get(conn, taskIdentity);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param taskIdentity
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<TaskIdentity> queryTaskIdentity(Connection conn, TaskIdentity taskIdentity) throws TspTransactionException {
        try {
            return taskIdentityService.query(conn, taskIdentity);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param taskIdentity
     * @return
     * @throws TspTransactionException
     */
    @Override
    public List<TaskIdentity> queryTaskIdentityPage(Connection conn, TaskIdentity taskIdentity) throws TspTransactionException {
        try {
            return taskIdentityService.queryPage(conn, taskIdentity);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobDetailParam
     * @return
     * @throws TspTransactionException 
     */
    @Override
    public int queryJobDetailParamSize(Connection conn, JobDetailParam jobDetailParam) throws TspTransactionException {
        try {
            return jobDetailParamService.querySize(conn, jobDetailParam);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobGroup
     * @return
     * @throws TspTransactionException
     */
    @Override
    public int queryJobGroupSize(Connection conn, JobGroup jobGroup) throws TspTransactionException {
        try {
            return jobGroupService.querySize(conn, jobGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param jobIdentityInfo
     * @return
     * @throws TspTransactionException 
     */
    @Override
    public int queryJobIdentityInfoSize(Connection conn, JobIdentityInfo jobIdentityInfo) throws TspTransactionException {
        try {
            return jobIdentityInfoService.querySize(conn, jobIdentityInfo);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param job
     * @return
     * @throws TspTransactionException 
     */
    @Override
    public int queryJobSize(Connection conn, Job job) throws TspTransactionException {
        try {
            return jobService.querySize(conn, job);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param slice
     * @return
     * @throws TspTransactionException 
     */
    @Override
    public int querySliceSize(Connection conn, Slice slice) throws TspTransactionException {
        try {
            return sliceService.querySize(conn, slice);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param sliceGroup
     * @return
     * @throws TspTransactionException 
     */
    @Override
    public int querySliceGroupSize(Connection conn, SliceGroup sliceGroup) throws TspTransactionException {
        try {
            return sliceGroupService.querySize(conn, sliceGroup);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }

    /**
     * 功能说明:
     * 
     * @param conn
     * @param taskIdentity
     * @return
     * @throws TspTransactionException 
     */
    @Override
    public int queryTaskIdentitySize(Connection conn, TaskIdentity taskIdentity) throws TspTransactionException {
        try {
            return taskIdentityService.querySize(conn, taskIdentity);
        } catch (TspException e) {
            throw new TspTransactionException(e);
        }
    }
    
}
